# models.py
from django.contrib.auth.models import AbstractUser
from django.db import models


class User(AbstractUser):
    ROLE_CHOICES = (
        ('user', '普通用户'),
        ('admin', '管理员'),
    )

    role = models.CharField(max_length=10, choices=ROLE_CHOICES, default='user')

    def __str__(self):
        return self.username

    class Meta(AbstractUser.Meta):
        # 确保模型可以被替换
        swappable = 'AUTH_USER_MODEL'
